/**
 * 
 */
package in.ac.nitw.imageProcessor;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 * @author kislay
 * 
 */
public class MagnificationTransformer implements ImageTransformer {

    private double zoomLevel;

    /**
     * @return the zoomLevel
     */
    public double getZoomLevel() {
	return zoomLevel;
    }

    /**
     * @param zoomLevel
     *            the zoomLevel to set in percentage
     */
    public void setZoomLevel(double zoomLevel) {
	this.zoomLevel = zoomLevel / 100;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * in.ac.nitw.imageProcessor.ImageTransformer#applyTransformation(java.awt
     * .image.BufferedImage)
     */
    @Override
    public BufferedImage applyTransformation(BufferedImage image) {
	int newImageWidth = (int) (image.getWidth() * zoomLevel);
	int newImageHeight = (int) (image.getHeight() * zoomLevel);
	BufferedImage resizedImage = new BufferedImage(newImageWidth,
		newImageHeight, image.getType());
	Graphics2D g = resizedImage.createGraphics();
	g.drawImage(image, 0, 0, newImageWidth, newImageHeight, null);
	g.dispose();
	return resizedImage;
    }

}
